(function(){
	"use strict";
	
	var $findForm;
	var $listResultEL;
	
	$(function(){
		$findForm=$("#findForm");
		$listResultEL=$("#listResultEL");
		$findForm.submit(handleFindFormSubmit).submit();
		
		
	});
	
	var handleFindFormSubmit=function(evt){
		evt.preventDefault();
		//显示加载动画
		showLoading($listResultEL);
		var url="/api/system/role/list";
		$.get(url,$findForm.serialize(),function(resp){
			if(resp.code==="ok"){
				var rows=resp.data;
				if(rows.length>0){
					paintResult(rows);
				}else{
					paintNoResult();
				}
			}
		});
	};
	
	
	
	var paintResult=function(rows){
		var html="";
		for(var i=0,len=rows.length;i<len;i++){
			var row=rows[i];
			html+='<tr>';
            html+='<td>'+(i+1)+'</td>';
            html+='<td>';
            html+='<a href="check.html#'+row.id+'" >查看</a>';
            html+="</td>";
            html+='<td>'+row.code+'</td>';
            html+="<td>"+row.name+"</td>";
            html+="<td>"+$$(row.remark)+"</td>"
            html+="</tr>";
		}
		$listResultEL.html(html);
		
		
		
	};
	
	var paintNoResult=function(){
		var html="<tr><td colspan='99999'>";
		html+="很抱歉，未找到相关数据";
		html+="</td></tr>"
		$listResultEL.html(html);
	};
	
	
	var showLoading=function(box){
		var html='<div class="loader-wrapper">';
		html+='<div class="loader">';
		html+='    <div class="roller"></div>';
		 html+='   <div class="roller"></div>';
		 html+=' </div>';
  
	html+='  <div id="loader2" class="loader">';
	 html+='   <div class="roller"></div>';
	html+='    <div class="roller"></div>';
	 html+=' </div>';
  
	html+='  <div id="loader3" class="loader">';
	 html+='   <div class="roller"></div>';
	 html+='   <div class="roller"></div>';
	 html+=' </div>';
	html+='</div>';

	box.html(html);



	};
	
	
	
	
})();
